<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第二个案例</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        ul {
            width: 400px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            display: flex;
            list-style: none;
            border: 1px solid black;
            margin: 0 auto;
            border: 1px solid green;
        }
        ul li {
            flex: 1;
            height: 30px;
            line-height: 30px;
            border-right: 1px solid green;
            color: green;
        }
        .top {
            width: 100px;
            height: 35px;
            line-height: 35px;
            display: flex;
            justify-content: space-around;
            margin: 10px auto;
        }
        .top .one {
            width: 20px;
            height: 20px;
            background-color: red;
        }
        .top .two {
            width: 20px;
            height: 20px;
            background-color: greenyellow;
        }
        .top .three {
            width: 20px;
            height: 20px;
            background-color: purple;
        }
        .body {
            width: 100%;
            height: 100%;
            background-color: #eee;
        }
    </style>
</head>
<body class="body">
    <div class="top">
        <div class="one"></div>
        <div class="two"></div>
        <div class="three"></div>
    </div>
    <ul>
        <li>新闻</li>
        <li>娱乐</li>
        <li>体育</li>
        <li>电影</li>
        <li>音乐</li>
        <li>旅游</li>
    </ul>
</body>
<script>
    var body = document.querySelector('.body')
    // 第一个盒子
    var one = document.querySelector('.one')
    one.onclick = function() {
        body.style.backgroundColor = 'red'
    }
    // 第二个盒子
    var two = document.querySelector('.two')
    two.onclick = function() {
        body.style.backgroundColor = 'greenyellow'
    }
    // 第三个盒子
    var three = document.querySelector('.three')
    three.onclick = function() {
        body.style.backgroundColor = 'purple'
    }
</script>
</html>